window.keyList = {
  key00: { label: "00", type: "num", val: "00" },
  key0: { label: "0", type: "num", val: "0" },
  key1: { label: "1", type: "num", val: "1" },
  key2: { label: "2", type: "num", val: "2" },
  key3: { label: "3", type: "num", val: "3" },
  key4: { label: "4", type: "num", val: "4" },
  key5: { label: "5", type: "num", val: "5" },
  key6: { label: "6", type: "num", val: "6" },
  key7: { label: "7", type: "num", val: "7" },
  key8: { label: "8", type: "num", val: "8" },
  key9: { label: "9", type: "num", val: "9" },
  key_diff: { label: "", type: "order", val: "diff" },
  key_submit: { label: "确定", type: "order", val: "submit" },
  key_back: { label: "退格", type: "order", val: "back" },
  key_clear: { label: "清空", type: "order", val: "clear" },
};
window.keyMap = [
  ["key7", "key8", "key9", "key_diff"],
  ["key4", "key5", "key6", "key_clear"],
  ["key1", "key2", "key3", "key_back"],
  ["key0", "key00", "key3", "key_submit"],
];

window.genEquation = function () {
  const _random = () => parseInt(Math.random() * 100);

  // 随机生成一个结果
  const res = _random();

  // 随机生成算式第2项
  const num2 = _random();

  let equationLis = [];

  if (res + num2 < 100) {
    // 判断是否可以生成减法算式
    // console.log(res + num2, num2, res);
    equationLis.push([res + num2, num2, res, "-"]);
  }

  if (res - num2 > 1) {
    // 判断是否可以生成加法算式
    // console.log(res - num2, num2, res);
    equationLis.push([res - num2, num2, res, "+"]);
  }

  if (equationLis.length == 0) {
    // console.log("return this.genEquation()");
    return this.genEquation();
  }

  if (equationLis.length == 1) {
    // console.log("return equationLis[0]");
    return equationLis[0];
  }

  // console.log("return equationLis[_random() % 2]");
  return equationLis[_random() % 2];
};
